package com.resou.reader.bookshelf.readhistory.datasupport;

import android.os.Parcel;
import android.os.Parcelable;

import org.litepal.crud.LitePalSupport;

/**
 * 阅读记录实体类
 * 用户进入阅读器后产生的书本的列表
 * Created by ${Garrett} on 2018/9/8.
 * Contact me krouky@outlook.com
 */
public class ReaderHistory extends LitePalSupport implements Parcelable {
    private String bookId;
    private String name;
    private String author;
    private String picUrl;
    private long createTime;//书的创建时间（来自后台）
    private String description;
    private long updateTime;//更新时间
    private String parentCategoryName;//父分类名称
    private String keywords;//关键词
    private String categoryName;//分类名称
    private float totalWord;
    private int serialStatus;//连载状态
    private String shareUrl;//分享链接
    private int chapterSum;//章节总数

    //添加字段+++++++++++++
    private String historyChapterId = "-1";//观看历史章节ID
    private String historyChapterName;//观看历史章节名称
    private int chapterIndex;//观看历史章节在总章节中的索引
    private int pageIndex;//页码
    private int charIndex;//字符在本章节中的索引
    private long userUpdateTime;//记录用户用户上次观看退出的时间
    private boolean isDeleted;  //是否删除
    //追书id
    private String zsBookId;
    private String lastChapterName;

    public String getLastChapterName() {
        return lastChapterName;
    }

    public void setLastChapterName(String lastChapterName) {
        this.lastChapterName = lastChapterName;
    }

    public String getZsBookId() {
        return zsBookId;
    }

    public void setZsBookId(String zsBookId) {
        this.zsBookId = zsBookId;
    }

    public int getChapterSum() {
        return chapterSum;
    }

    public void setChapterSum(int chapterSum) {
        this.chapterSum = chapterSum;
    }

    public String getShareUrl() {
        return shareUrl;
    }

    public void setShareUrl(String shareUrl) {
        this.shareUrl = shareUrl;
    }

    public String getHistoryChapterName() {
        return historyChapterName;
    }

    public void setHistoryChapterName(String historyChapterName) {
        this.historyChapterName = historyChapterName;
    }

    public int getSerialStatus() {
        return serialStatus;
    }

    public void setSerialStatus(int serialStatus) {
        this.serialStatus = serialStatus;
    }

    public float getTotalWord() {
        return totalWord;
    }

    public void setTotalWord(float totalWord) {
        this.totalWord = totalWord;
    }

    public long getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(long updateTime) {
        this.updateTime = updateTime;
    }

    public String getParentCategoryName() {
        return parentCategoryName;
    }

    public void setParentCategoryName(String parentCategoryName) {
        this.parentCategoryName = parentCategoryName;
    }

    public String getKeywords() {
        return keywords;
    }

    public void setKeywords(String keywords) {
        this.keywords = keywords;
    }

    public String getCategoryName() {
        return categoryName;
    }

    public void setCategoryName(String categoryName) {
        this.categoryName = categoryName;
    }

    public String getBookId() {
        return bookId;
    }

    public void setBookId(String bookId) {
        this.bookId = bookId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPicUrl() {
        return picUrl;
    }

    public void setPicUrl(String picUrl) {
        this.picUrl = picUrl;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public String getHistoryChapterId() {
        return historyChapterId;
    }

    public void setHistoryChapterId(String historyChapterId) {
        this.historyChapterId = historyChapterId;
    }

    public int getChapterIndex() {
        return chapterIndex;
    }

    public void setChapterIndex(int chapterIndex) {
        this.chapterIndex = chapterIndex;
    }

    public int getPageIndex() {
        return pageIndex;
    }

    public void setPageIndex(int pageIndex) {
        this.pageIndex = pageIndex;
    }

    public int getCharIndex() {
        return charIndex;
    }

    public void setCharIndex(int charIndex) {
        this.charIndex = charIndex;
    }

    public long getUserUpdateTime() {
        return userUpdateTime;
    }

    public void setUserUpdateTime(long userUpdateTime) {
        this.userUpdateTime = userUpdateTime;
    }

    public boolean isDeleted() {
        return isDeleted;
    }

    public void setDeleted(boolean deleted) {
        isDeleted = deleted;
    }

    public ReaderHistory() {
    }

    @Override
    public String toString() {
        return "ReaderHistory{" +
                "bookId='" + bookId + '\'' +
                ", name='" + name + '\'' +
                ", author='" + author + '\'' +
                ", picUrl='" + picUrl + '\'' +
                ", createTime=" + createTime +
                ", description='" + description + '\'' +
                ", updateTime=" + updateTime +
                ", parentCategoryName='" + parentCategoryName + '\'' +
                ", keywords='" + keywords + '\'' +
                ", categoryName='" + categoryName + '\'' +
                ", totalWord=" + totalWord +
                ", serialStatus=" + serialStatus +
                ", shareUrl='" + shareUrl + '\'' +
                ", chapterSum=" + chapterSum +
                ", historyChapterId='" + historyChapterId + '\'' +
                ", historyChapterName='" + historyChapterName + '\'' +
                ", chapterIndex=" + chapterIndex +
                ", pageIndex=" + pageIndex +
                ", charIndex=" + charIndex +
                ", userUpdateTime=" + userUpdateTime +
                ", isDeleted=" + isDeleted +
                ", zsBookId='" + zsBookId + '\'' +
                ", lastChapterName='" + lastChapterName + '\'' +
                '}';
    }

    @Override
    public int describeContents() {
        return 0;
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(this.bookId);
        dest.writeString(this.name);
        dest.writeString(this.author);
        dest.writeString(this.picUrl);
        dest.writeLong(this.createTime);
        dest.writeString(this.description);
        dest.writeLong(this.updateTime);
        dest.writeString(this.parentCategoryName);
        dest.writeString(this.keywords);
        dest.writeString(this.categoryName);
        dest.writeFloat(this.totalWord);
        dest.writeInt(this.serialStatus);
        dest.writeString(this.shareUrl);
        dest.writeInt(this.chapterSum);
        dest.writeString(this.historyChapterId);
        dest.writeString(this.historyChapterName);
        dest.writeInt(this.chapterIndex);
        dest.writeInt(this.pageIndex);
        dest.writeInt(this.charIndex);
        dest.writeLong(this.userUpdateTime);
        dest.writeByte(this.isDeleted ? (byte) 1 : (byte) 0);
        dest.writeString(this.zsBookId);
        dest.writeString(this.lastChapterName);
    }

    protected ReaderHistory(Parcel in) {
        this.bookId = in.readString();
        this.name = in.readString();
        this.author = in.readString();
        this.picUrl = in.readString();
        this.createTime = in.readLong();
        this.description = in.readString();
        this.updateTime = in.readLong();
        this.parentCategoryName = in.readString();
        this.keywords = in.readString();
        this.categoryName = in.readString();
        this.totalWord = in.readFloat();
        this.serialStatus = in.readInt();
        this.shareUrl = in.readString();
        this.chapterSum = in.readInt();
        this.historyChapterId = in.readString();
        this.historyChapterName = in.readString();
        this.chapterIndex = in.readInt();
        this.pageIndex = in.readInt();
        this.charIndex = in.readInt();
        this.userUpdateTime = in.readLong();
        this.isDeleted = in.readByte() != 0;
        this.zsBookId = in.readString();
        this.lastChapterName = in.readString();
    }

    public static final Creator<ReaderHistory> CREATOR = new Creator<ReaderHistory>() {
        @Override
        public ReaderHistory createFromParcel(Parcel source) {
            return new ReaderHistory(source);
        }

        @Override
        public ReaderHistory[] newArray(int size) {
            return new ReaderHistory[size];
        }
    };
}
